<%@ page import="com.scalar.chiptrack.utils.ConfigManager, java.util.Calendar"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/financeReport.do?action=ProjectionLots" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); try{%>

<%
    String processType      = request.getParameter("processType");
    String productId        = request.getParameter("product");
    boolean customervisibleflag = false;

    if( processType == null || ( processType != null && processType.trim().length() == 0 ) )
    {
        processType = "0";
    }
    if(  processType != null && processType.trim().length() >= 0 && "Class Store".equalsIgnoreCase( processType ) )
    {
        customervisibleflag = true;
    }
    if( productId == null || ( productId != null && productId.trim().length() == 0 ) )
    {
        productId = "0";
    }
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>

<SCRIPT language="JavaScript">

var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}
function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function getProductsForProcess()
{
    document.lotsProjectionReport.action="<%=chipTracContext%>/financeReport.do?action=ProjectionLots&processType="+document.lotsProjectionReport.processType.value;
    document.lotsProjectionReport.submit();
}


function dateRange()
{
    var d = new Date();
    var day = d.getDate();
    var month = d.getMonth()+1;
    var year = d.getFullYear();
    var hour = d.getHours();
    var min = d.getMinutes();
    var sec = d.getSeconds();

    var reportName = document.lotsProjectionReport.reportname.value;

    var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    var success;
    success = true;

    if(success == false)
    {
       return false;
    }
   	var pa	= document.getElementById("errors")
	pa.innerHTML = errMsg;
	if (document.lotsProjectionReport.processType.value == '0' || document.lotsProjectionReport.processType.value == null)
	{
		pa.innerHTML = "<li> Please select Process Type ";
        return false;
	}

if (document.lotsProjectionReport.processType.value == '')
        document.lotsProjectionReport.prompt0.value='0';
    else
        document.lotsProjectionReport.prompt0.value = document.lotsProjectionReport.processType.value;

    if(document.lotsProjectionReport.products.value=='')
    {
        document.lotsProjectionReport.prompt1.value ='0';
    }
    else
    {
        document.lotsProjectionReport.prompt1.value =document.lotsProjectionReport.products.value;
    }
    if (document.lotsProjectionReport.fromvendor.value=='')
    {
        document.lotsProjectionReport.prompt2.value = '0';
    }
    else
    {
        document.lotsProjectionReport.prompt2.value = document.lotsProjectionReport.fromvendor.value;
    }

        document.lotsProjectionReport.prompt3.value=defaultPrompt;
        document.lotsProjectionReport.prompt4.value ='';
        document.lotsProjectionReport.prompt5.value ='';
        document.lotsProjectionReport.prompt6.value ='';
        document.lotsProjectionReport.prompt7.value ='';
        document.lotsProjectionReport.prompt8.value ='';
        document.lotsProjectionReport.prompt9.value ='';
        document.lotsProjectionReport.prompt10.value='';
        document.lotsProjectionReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Lot_Projection_Report.rpt";

}

function loadProducts()
{
	document.lotsProjectionReport.action="<%=chipTracContext%>/financeReport.do?action=ProjectionLots";
	document.lotsProjectionReport.submit();
}


function clearErrors()
{
    var pa=document.getElementById("errors");
    pa.innerHTML = "";
}
function reset()
{
   document.lotsProjectionReport.processType.value =0;
   return true;
}


</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD bgcolor="#ffffff">
            <form name="lotsProjectionReport" method="post">
            <input type="hidden" name="prompt0">
            <input type="hidden" name="prompt1">
            <input type="hidden" name="prompt2">
            <input type="hidden" name="prompt3">
            <input type="hidden" name="prompt4">
            <input type="hidden" name="prompt5">
            <input type="hidden" name="prompt6">
            <input type="hidden" name="prompt7">
            <input type="hidden" name="prompt8">
            <input type="hidden" name="prompt9">
            <input type="hidden" name="prompt10">
            <input type="hidden" name="reportname" value="<%=request.getParameter("reportname")%>">
        </TD>
        <TD valign="top" width="100%">
            <table border="0" width="100%" align="center">
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <TD width="100%" COLSPAN="6">
                        <TABLE width="100%" align=right border="0">
                            <TR>
                                <TD width="25%">&nbsp;</TD>
                                <TD width="65%" class="NArialW">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Lots Projection Report</TD>
                                <TD width="10%">&nbsp;</TD>
                            </TR>
                        </TABLE>
                    </TD>
                </tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <td width="15%">&nbsp;</td>
                    <td width="85%" colspan="5" align="left">
                        <b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font><b>&nbsp;
                    </td>
                </tr>
                <TR>
                    <TD colspan="6" width="100%">
                        <Table Border="0" width="100%" cellSpacing="0" cellPadding="0">
                            <TR>
                                <TD width="12%">&nbsp;</TD>
                                <TD width="12%" valign="top" class=NArialL>Process Type</TD>
                                <TD width="25%" valign="top" class=NArialL>
                                   <select size="1" name="processType" class="txfield"  onChange="getProductsForProcess()">
                                       <option value="0">Select Process Type</option>
                                        <logic:iterate id="processList" name="processList" >
                                            <logic:equal name="processList" property="value" value="<%=processType%>"><option value="<bean:write name="processList" property="value"/>" selected><bean:write name="processList" property="label"/></option></logic:equal>
                                            <logic:notEqual name="processList" property="value" value="<%=processType%>"><option value="<bean:write name="processList" property="value"/>"><bean:write name="processList" property="label"/></option></logic:notEqual>
                                        </logic:iterate>
                                   </select>
                                </TD>
                           </TR>
                           <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                           <TR>
                                <TD width="12%">&nbsp;</TD>
                                <TD width="12%" valign="top" class=NArialL>Product Name<br>(<bean:message key = "label.mfgPartNumber" />)</TD>
                                <TD width="30%" valign="top" class=NArialL>
                                	<select size="1" name="products" class="txfield" >
                                        <option value="0" selected>All Products</option>
                                        <logic:iterate id="mktgPartNumberSelectList" name="productList" >
                                        	<logic:notEqual name="mktgPartNumberSelectList" value="null">
                                                <option value="<bean:write name="mktgPartNumberSelectList" property="value"/>" >
                                                    <bean:write name="mktgPartNumberSelectList" property="label"/>
                                                </option>
                                            </logic:notEqual>
                                        </logic:iterate>
                                    </select>
                                </TD>
                            </TR>
                            <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                            <TR>
                                <TD width="12%">&nbsp;</TD>
                                <TD width="12%" valign="top" class=NArialL>Vendor Name</TD>
                                <TD width="25%" valign="top" class=NArialL>
                                    <select size="1" name="fromvendor" class="txfield"  >
                                        <option value="0" selected>All Vendors</option>
                                        <logic:iterate id="vendorList" name="vendorList" >
                                            <logic:notEqual name="vendorList" value="null">
												<option value ="<bean:write name="vendorList" property="value"/>" >
													<bean:write name="vendorList" property="label"/>
												</option>
											</logic:notEqual>
                                        </logic:iterate>
                                    </select>
                                </TD>
                             </TR>
                        </Table>
                    </TD>
                </TR>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>&nbsp;</td></tr>
                <tr>
                    <td width="30%" colspan="2"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>&nbsp;</td>
                    <td width="70%"  colspan="4" align="left">
                        <input type="image" onClick="javascript:return dateRange();"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:document.lotsProjectionReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
                    </td>
                </tr>
            </table>
            <BR><BR><BR>
            </form>
        </TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
<% }catch(Exception e){e.printStackTrace();} %>